<form action="<?php e_qus(); ?>" method="get">
    <fieldset>
        <legend></legend>
        <label for="id">ID</label><br/>
        <input id="id" name="id" type="text" placeholder="请输入要搜索的订单ID"><br/>
        <label for="username">实际购买人联系方式</label><br/>
        <input id="username" name="username" type="text" placeholder="请输入实际购买人联系方式"><br/>
        <label for="orderState">订单状态</label>
        <select name="state" id="orderState">
            <option value="" >所有</option>
            <?php foreach($r['orderState'] as $k=>$v){ ?>
                <option value="<?=$k?>" <?php if($k==$r['currentState']) echo "selected";?>><?=$v?></option>
            <?php } ?>
        </select>
        <label for="serviceId">服务站名称</label>
        <select name="serviceId" id="serviceId">
            <option value='' >所有</option>
            <?php foreach($r['service'] as $v){?>
                <option value="<?php echo $v['id']?>" <?php if($r['serviceId']==$v['id']) echo 'selected'?> ><?php echo $v['service_name']?></option>
            <?php }?>
        </select>
        <input type="submit" value="搜 索"/><br/><br/>
    </fieldset>
</form>
<?php if(empty($r['list'])){ echo "亲，暂时还没有普通商品订单哦~"?>
    <?php }else{?>

<table id="dataTable">
    <thead>
    <tr>
        <th>ID</th>
        <th>当前状态</th>
        <th>下单/支付时间</th>
        <th>发货时间</th>
        <th>到站时间</th>
        <th>配送时间</th>
        <th>订单金额</th>
        <th>付款金额</th>
        <th>选择服务站</th>
        <th>服务站地址</th>
<!--        <th>用户电话</th>-->
<!--        <th>用户地址</th>-->
        <th>操作</th>
    </tr>
    </thead>
    <tbody>
    <?php foreach($r['list'] as $v){?>
        <tr>
            <td><?php echo $v['id'];?></td>
            <td><?=$r['orderState'][$v['state']]; ?></td>
            <td>
                <?php if(!empty($v['payment_time'])){ ?>
                    <?=$v['payment_time']?>
                <?php }elseif($v['state']=="unpaid"){ ?>
                    <a href="<?php e_action("dealUrgePay","order_id=".$v['id'])?>">催促付款</a>
                    <a href='<?php e_action("dealClose","order_id={$v['id']}");?>' onclick="return confirm('确定取消订单吗？');">取消订单</a>
                <?php } ?>
            </td>

            <td>
                <?php if(!empty($v['shipping_time'])){ ?>
                    <?=$v['shipping_time']?>
                <?php }elseif($v['state']=="unshipped"){ ?>
                    <a href="<?php e_action("dealSend","order_id=".$v['id'])?>">点击发货并记录运单号</a>
                <?php } ?>
            </td>
            <td>
                <?php if(!empty($v['service_time'])){ ?>
                    <?=$v['service_time']?>
                <?php }elseif(($v['state']=="shipped")&&(!empty($v['service_id']))){ ?>
                    <a href="<?php e_action("dealTipService","order_id=".$v['id'])?>">提醒一下服务站</a>
                <?php } ?>
            </td>
            <td>
                <?php if(!empty($v['delivery_time'])){ ?>
                    <?=$v['delivery_time']?>
                <?php }elseif($v['state']=="service"){ ?>
                    <a href="<?php e_action("dealUrgeService","order_id=".$v['id'])?>">催一下服务站</a>
                <?php } ?>
            </td>
            <td>￥<?php echo $v['order_amount'];?></td>
            <td>￥<?php echo $v['payment_amount'];?></td>
            <td><?php echo $v[$v['id']]['service_name']?></td>
            <td><?php echo $v[$v['id']]['service_address']?></td>
<!--            <td>--><?php //echo $v[$v['id']]['username']?><!--</td>-->
<!--            <td>--><?php //echo $v[$v['id']]['userAddress']?><!--</td>-->

            <td><a href="<?php e_action("detail","id={$v['id']}")?>">订单详情</a></td>

        </tr>
    <?php } ?>
    </tbody>
</table>
<?php echo $r['page']->getPageHtml(); ?>
<?php }?>